#include "KylinDaqCommon.h" 

qlonglong secToMsec(qlonglong sec)
{
    return sec*gs_secToMsec;
}

int getValidConfInt(const QJsonObject &conf ,const QJsonObject &defaultConf, const QString &key, qlonglong &value)
{
    if(defaultConf.contains(key)
       && defaultConf[key].isObject()
       && defaultConf[key].toObject().contains(gs_defaultStr))
    {
        QJsonObject defaultConfKeyObj = defaultConf[key].toObject();
        if(conf.contains(key)
           && defaultConfKeyObj.contains(gs_maxStr)
           && defaultConfKeyObj.contains(gs_minStr))
        {
            value = compareValue(conf[key].toVariant().toLongLong()
                         ,defaultConfKeyObj[gs_maxStr].toVariant().toLongLong()
                         ,defaultConfKeyObj[gs_minStr].toVariant().toLongLong()
                         ,defaultConfKeyObj[gs_defaultStr].toVariant().toLongLong());
        }
        else {
           value = defaultConfKeyObj[gs_defaultStr].toVariant().toLongLong();
        }
    }
    else {
       return -1;
    }
    return 0;
}
